package com.skrabacz.kinetic.buisness.aspect;

import javax.management.InvalidAttributeValueException;

import com.skrabacz.kinetic.buisness.check.Checker;
import com.skrabacz.kinetic.buisness.check.ParamsChecker;
import com.skrabacz.kinetic.buisness.logic.Point;
import com.skrabacz.kinetic.buisness.logic.ResultTreeSet;
import com.skrabacz.kinetic.buisness.logic.Matrix;

public aspect CheckerAspect {
	private Checker checker = new ParamsChecker();

	pointcut paramCheckers(Object object) : (execution(* ResultTreeSet.addPoint(Point)) && args(object));

	before(Object object) : paramCheckers(object) {
		checker.checkParams(object);
	}

	pointcut paramNumberCheckers(int... cor) : (execution(* Matrix.getPoint(int ...)) && args(cor));

	before(int[] cor) throws InvalidAttributeValueException : paramNumberCheckers(cor) {
		checker.checkNumberParams(cor);
	}

	after(Matrix m) returning: this(m) && initialization(Matrix.new(..)) {
		m.updateMatrixParams();
	}
}
